package com.demo.dao;

import com.demo.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IUserDao2 {
    /**
     * 根据id查询用户数据
     */
    @Select("select * from tb_user where id = #{id}")
    public User getById(Integer id);
    /**
     * 查询所有用户
     */
    @Select("select * from tb_user")
    public List<User> getAll();
    /**
     * 添加用户
     */
    @Insert("insert into tb_user(user_name,password,name,age,sex,birthday,created,updated) values(#{username},#{password},#{name},#{age},#{sex},#{birthday},#{created},#{updated})")
    public Integer insertUser(User user);
    /**
     * 修改用户
     */
    @Update("update tb_user set user_name = #{username},password = #{password},name = #{name},age = #{age},sex = #{sex},birthday = #{birthday},created = #{created},updated = #{updated} where id = #{id}")
    public Integer changeUser(User user);
    /**
     * 删除用户
     */
    @Delete("delete from tb_user where id = #{id}")
    public Integer removeUser(Integer id);

}
